

from pathlib import Path
import logging

from loguru import logger


# logging.basicConfig(filename='logTest1.log', level=logging.DEBUG, filemode='a', format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# logger = logging.getLogger()
# logger.warning("Warning: There\'s no GPU available on this machine, training will be performed on CPU.")

class LogClass:
    def __init__(self):
        self.logger = logger
        logger.add("../log/logTest1.log",rotation="00:00")

        # logger.debug("That's it, beautiful and simple logging!")
        # logger.info("That's it, beautiful and simple logging!")

    '''
    支持装饰器方式
    @logger.catch
    def my_function(self,x, y, z):
        # An error? It's caught anyway!
        return 1 / (x + y + z)
    '''



    # init_logger(log_file=config['log_dir'] / f'{args.arch}-{time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime())}.log')
    # def init_logger(log_file=None, log_file_level=logging.NOTSET):
    #     '''
    #     Example:
    #         >>> init_logger(log_file)
    #         >>> logger.info("abc'")
    #     '''
    #     if isinstance(log_file, Path):
    #         log_file = str(log_file)
    #     log_format = logging.Formatter(fmt='%(asctime)s - %(levelname)s - %(name)s -   %(message)s',
    #                                    datefmt='%m/%d/%Y %H:%M:%S')
    #
    #     logger = logging.getLogger()
    #     logger.setLevel(logging.INFO)
    #     console_handler = logging.StreamHandler()
    #     console_handler.setFormatter(log_format)
    #     logger.handlers = [console_handler]
    #     if log_file and log_file != '':
    #         file_handler = logging.FileHandler(log_file)
    #         file_handler.setLevel(log_file_level)
    #         # file_handler.setFormatter(log_format)
    #         logger.addHandler(file_handler)
    #     return logger


